package com.tianshu.easyexcel;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import lombok.extern.slf4j.Slf4j;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName SpringBootApplication
 * @Author 廖杰
 * @Date 2021/11/15 14:48
 */
@Slf4j
public class UserListener extends AnalysisEventListener<User> {

    private final List<User> users = new ArrayList<>();

    public UserListener() {
        log.info("UserListener 构造方法被执行...");
    }

    @Override
    public void invoke(User data, AnalysisContext context) {
        users.add(data);

    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext context) {
        log.info("数据读取完毕,users = {}", users);
    }
}
